package com.zone.trigger.listener;

import com.zone.domain.acticity.service.IActivitySkuStock;
import com.zone.types.event.BaseMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: zongzi
 * @description: 活动库存清0，消息消费者
 * @date: 2025/2/16
 */
@Slf4j
@Component
public class ActivitySkuZeroConsumer {
    @Autowired
    private IActivitySkuStock activitySkuStock;

    @RabbitListener(queuesToDeclare = @Queue(value = "${spring.rabbitmq.topic.activity_sku_zero}"))
    public void consumer(BaseMessage<Long> message) {
        log.info("activity sku stock zero consumer = {}", message);
        Long sku = message.getData();
        // 活动库存清0
        activitySkuStock.clearZeroActivitySkuCount(sku);
    }
}
